Seed CLI telemetry session IDs from CI workflow context - #54447
Conversation
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/d2467965-adc9-4e5a-a8c2-9076fee7b771 Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/d2467965-adc9-4e5a-a8c2-9076fee7b771 Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the .NET SDK CLI telemetry implementation to allow CI systems to correlate multiple dotnet invocations by seeding the in-process telemetry session ID from DOTNET_CLI_TELEMETRY_SESSIONID, and adds test/doc/CI updates to support that workflow.
Changes:
- Seed
TelemetryClient.CurrentSessionIdfromDOTNET_CLI_TELEMETRY_SESSIONIDwhen no explicit session ID is provided. - Add/adjust tests to validate environment seeding, explicit session ID precedence, and MSBuild forwarding behavior.
- Document the new environment variable and set it in selected CI YAML definitions.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/Cli/dotnet/Telemetry/TelemetryClient.cs |
Seeds session ID from DOTNET_CLI_TELEMETRY_SESSIONID before falling back to GUID generation. |
test/dotnet.Tests/TelemetryTests/TelemetryClientTests.cs |
Adds unit coverage for environment-seeded vs explicit session ID behavior; serializes tests touching static telemetry state. |
test/dotnet.Tests/CommandTests/MSBuild/GivenMsbuildForwardingApp.cs |
Adds coverage ensuring MSBuild forwarding propagates the seeded telemetry session ID. |
documentation/project-docs/telemetry.md |
Documents DOTNET_CLI_TELEMETRY_SESSIONID and clarifies session ID may be non-GUID correlation identifiers. |
src/Cli/dotnet/README.md |
Adds DOTNET_CLI_TELEMETRY_SESSIONID to CLI environment variable documentation. |
.github/workflows/copilot-setup-steps.yml |
Sets DOTNET_CLI_TELEMETRY_SESSIONID in the Copilot setup workflow environment. |
.vsts-pr.yml |
Sets DOTNET_CLI_TELEMETRY_SESSIONID in AzDO PR pipeline variables. |
.vsts-ci.yml |
Sets DOTNET_CLI_TELEMETRY_SESSIONID in AzDO CI pipeline variables. |
| // Other in-process tests (GivenADotnetFirstTimeUseConfigurerWithStateSetup) use "test" | ||
| // for session ID, so ignore if they already set it | ||
| if (sessionId != "test") | ||
| { | ||
| (sessionId == null || Guid.TryParse(sessionId, out _)) | ||
| .Should().BeTrue("DOTNET_CLI_TELEMETRY_SESSIONID should be null or current session id"); | ||
| } |
|
Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label. |
|
@copilot please fix the merge conflicts in this pull request. |
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Fixed by merging |
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
|
Only question I have is how do we ensure future yml changes end up including this change. Should we update a doc somewhere so copilot sees that when adding/editing yml in the future? Can be a separate PR. |
|
Another thought I had was how to get this into arcade so we seed the session id for all our repo builds. Not sure how to seed it into all workflows as those don't go through arcade. |
Good thought - will poke an agent/get a note into our reviewer docs/skills.
Also a great idea - will log an issue for this at the arcade repo for discussion. |
The CLI had a per-process telemetry session ID, but no first-class way to correlate multiple
dotnetinvocations that belong to the same CI workflow. This updates the CLI to honorDOTNET_CLI_TELEMETRY_SESSIONIDas the initial session seed and documents how CI integrations can set it consistently.CLI session seeding
TelemetryClientnow usesDOTNET_CLI_TELEMETRY_SESSIONIDwhen no explicit session ID is provided.MSBuild forwarding coverage
TelemetryClient.CurrentSessionIdDOTNET_CLI_TELEMETRY_SESSIONIDDocs
DOTNET_CLI_TELEMETRY_SESSIONIDin telemetry docs and CLI README.dotnetinvocations inherit it.Repo CI integration
Example: